package com.yaorange.nongjt.web.controller.system;

import com.yaorange.nongjt.certificate.domain.NjtYtjPos;
import com.yaorange.nongjt.certificate.service.INjtPosService;
import com.yaorange.nongjt.common.annotation.Log;
import com.yaorange.nongjt.common.core.controller.BaseController;
import com.yaorange.nongjt.common.core.domain.AjaxResult;
import com.yaorange.nongjt.common.core.page.TableDataInfo;
import com.yaorange.nongjt.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 一体打印机服务点
 *
 * @author coach tam
 * @email 327395128@qq.com
 * @values 坚持灵活 灵活坚持
 * @since 2024/10/10
 */
@RestController
@RequestMapping("/system/pos")
public class SysPosController extends BaseController {

    @Autowired
    private INjtPosService INjtPosService;
    @GetMapping("/list")
    @PreAuthorize("@ss.hasPermi('system:pos:list')")
    public TableDataInfo list(NjtYtjPos pos){
        startPage();
        List<NjtYtjPos> list =  INjtPosService.selectPosList(pos);
        return getDataTable(list);
    }


    @PostMapping
    @PreAuthorize("@ss.hasPermi('system:pos:add')")
    @Log(title = "新增一体打印机服务点", businessType = BusinessType.INSERT)
    public AjaxResult add(@RequestBody NjtYtjPos njtYtjPos) {
        return toAjax(INjtPosService.insertPos(njtYtjPos));
    }

    @PutMapping
    @PreAuthorize("@ss.hasPermi('system:pos:update')")
    @Log(title = "修改一体打印机服务点", businessType = BusinessType.UPDATE)
    public AjaxResult update(@RequestBody NjtYtjPos njtYtjPos) {
        return toAjax(INjtPosService.updatePos(njtYtjPos));
    }


    @DeleteMapping("/{ids}")
    @PreAuthorize("@ss.hasPermi('system:pos:delete')")
    @Log(title = "删除一体打印机服务点", businessType = BusinessType.DELETE)
    public AjaxResult delete(@PathVariable("ids") Long[] ids) {
        return toAjax(INjtPosService.deletePos(ids));
    }


}
